package com.micro.modual.service.impl;

import com.micro.common.MicroResponseCode;
import com.micro.core.exception.BizException;
import com.micro.core.frame.service.impl.AbstractBasicsServiceImpl;
import com.micro.core.resp.RespJson;
import com.micro.modual.entity.AppointmentRecord;
import com.micro.modual.extension.AppointmentRecordExtension;
import com.micro.modual.mapper.AppointmentRecordMapper;
import com.micro.modual.model.bo.appointmentrecord.AppointmentRecordBO;
import com.micro.modual.service.AppointmentRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
*  <h1>预约记录表  实现</h1>
 * @author LevelCoder
 * @version V1.0.0
 * @email LevelCoder@126.com
 * @date 2020-08-04 00:11:10
 */
@Service("appointmentRecordService")
public class AppointmentRecordServiceImpl extends AbstractBasicsServiceImpl<AppointmentRecord,Long> implements AppointmentRecordService {

    @Autowired
    private AppointmentRecordMapper appointmentRecordMapper;

    /**
     * <h2>新增预约记录表详情</h2>
     * @param appointmentRecordBO {@link AppointmentRecordBO} 预约记录表 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @Override
    public RespJson addAppointmentRecord(AppointmentRecordBO appointmentRecordBO) {
        AppointmentRecord appointmentRecord = AppointmentRecordExtension.converAddAppointmentRecord(appointmentRecordBO);
        appointmentRecordMapper.insertSelective(appointmentRecord);
        return new RespJson(MicroResponseCode.SUCCESS.getResponseCode(), MicroResponseCode.SUCCESS.getResponseMessage());
    }

    /**
     * <h2>修改预约记录表详情</h2>
     * @param appointmentRecordBO  {@link AppointmentRecordBO} 预约记录表 新增/修改 请求对象
     * @return {@link RespJson} 返回结果基础类
     */
    @Override
    public RespJson editAppointmentRecord(AppointmentRecordBO appointmentRecordBO) {
        AppointmentRecord appointmentRecord = AppointmentRecordExtension.converEditAppointmentRecord(appointmentRecordBO);
        appointmentRecordMapper.updateByPrimaryKeySelective(appointmentRecord);
        return new RespJson(MicroResponseCode.SUCCESS.getResponseCode(),MicroResponseCode.SUCCESS.getResponseMessage());

    }

    /**
     * <h2>根据主键编号删除预约记录表信息</h2>
     * @param id  预约记录表 主键编号
     * @return  {@link RespJson} 返回结果基础类
     */

    @Override
    public RespJson deleteAppointmentRecord(Long id) {
        appointmentRecordMapper.deleteByPrimaryKey(id);
        return new RespJson(MicroResponseCode.SUCCESS.getResponseCode(),MicroResponseCode.SUCCESS.getResponseMessage());
    }

}
